package org.playground.booking.entity;

import org.hibernate.Transaction;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "payment_transaction")
public class PaymentTransaction extends PlaygrounEntity{
    /*
    *   transaction_id bigint AUTO_INCREMENT PRIMARY KEY ,
  booking_id bigint NOT NULL ,
  amount INT not NULL ,
  transaction_status_id bigint not null,
  appid BIGINT NOT NULL ,
  booking bigint NOT NULL ,
  created DATE
    *
    *
    * */
    @Id
    @Column(name = "transaction_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long transactionId;
    @Column(name = "amount")
    private int amount;
    @ManyToOne(targetEntity = TransactionStatus.class,cascade = CascadeType.ALL)
    @JoinColumn(name = "transaction_status_id")
    private TransactionStatus transactionStatus;
    @ManyToOne(targetEntity = WechatMerchantAccount.class,cascade = CascadeType.ALL)
    @JoinColumn(name = "appid")
    private WechatMerchantAccount wechatMerchantAccount;
    @Column(name = "created")
    private Date created;
    @ManyToOne(targetEntity = Booking.class,cascade = CascadeType.ALL)
    @JoinColumn(name = "bookingid")
    private Booking booking;
    //TODO transactionlogs
    //private List<Transaction>
    @OneToMany(targetEntity = PaymentTransactionLog.class,cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "transaction_id")
    private List<PaymentTransactionLog> transactionLogs;


    public Long getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(Long transactionId) {
        this.transactionId = transactionId;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public TransactionStatus getTransactionStatus() {
        return transactionStatus;
    }

    public void setTransactionStatus(TransactionStatus transactionStatus) {
        this.transactionStatus = transactionStatus;
    }

    public WechatMerchantAccount getWechatMerchantAccount() {
        return wechatMerchantAccount;
    }

    public void setWechatMerchantAccount(WechatMerchantAccount wechatMerchantAccount) {
        this.wechatMerchantAccount = wechatMerchantAccount;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Booking getBooking() {
        return booking;
    }

    public void setBooking(Booking booking) {
        this.booking = booking;
    }

    public List<PaymentTransactionLog> getTransactionLogs() {
        return transactionLogs;
    }

    public void setTransactionLogs(List<PaymentTransactionLog> transactionLogs) {
        this.transactionLogs = transactionLogs;
    }
}
